package tech.yozo.bamboo.ui.style;

import android.text.style.ClickableSpan;
import android.view.View;

import androidx.annotation.NonNull;

/**
 * 单词点选样式组件
 */
public class WordSpan extends ClickableSpan {
    private final String mWord;

    private OnClickListener mOnClickListener;

    public WordSpan(String word) {
        mWord = word;
    }

    public String getWord() {
        return mWord;
    }

    public void setOnClickListener(OnClickListener listener) {
        mOnClickListener = listener;
    }

    @Override
    public void onClick(@NonNull View widget) {
        if (mOnClickListener != null) {
            mOnClickListener.onClicked(this);
        }
    }

    public interface OnClickListener {
        public void onClicked(WordSpan wordSpan);
    }
}
